package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo16cartesian {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setMaster("local")
      .setAppName("Demo14Agg")


    val sc = new SparkContext(conf)


    val namesRDD: RDD[(String, String)] = sc.makeRDD(List(("001", "张三"), ("002", "李四")))
    val agesRDD: RDD[(String, Int)] = sc.makeRDD(List(("002", 24), ("003", 25)))

    /**
      * 笛卡尔积
      *
      */

    val cartesianRDD: RDD[((String, String), (String, Int))] = namesRDD.cartesian(agesRDD)

    cartesianRDD.foreach(println)

  }

}
